<%--
  Created by IntelliJ IDEA.
  User: caidao
  Date: 2023/4/23
  Time: 16:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>消费记录</title>
    <jsp:include page="/include/bootstrapHeader.jsp"/>
    <link rel="stylesheet" href="<c:url value="/css/main.css"/>">
</head>
<body class="d-flex flex-column h-100">
    <jsp:include page="/include/header.jsp"/>
    <main class="flex-shrink-0">
        <div class="container">
            <h1 class="mt-5">记录每天的消费情况</h1>
            <c:if test="${sessionScope.msg != '' && sessionScope.msg != null}">
                <div class="alert alert-primary" role="alert">
                    <c:out value="${sessionScope.msg}"/>
                    <c:set var="msg" scope="session" value=""/>
                </div>
            </c:if>
            <table class="table">
                <thead>
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">商品名称</th>
                    <th scope="col">支出类型</th>
                    <th scope="col">支出时间</th>
                    <th scope="col">支出金额</th>
                    <th scope="col">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="paid" varStatus="status" items="${list}">
                <tr>
                    <td><c:out value="${status.index + 1}" /></td>
                    <td><c:out value="${paid.paidName}" /></td>
                    <td><c:out value="${paid.paidType}" /></td>
                    <td>
                        <%--<c:out value="${paid.paiddate}" />--%>
                        <fmt:formatDate value="${paid.paidDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
                    </td>
                    <td><c:out value="${paid.amountPaid}" /></td>
                    <td>
                        <a href="<c:url value="/paid/edit?id=${paid.id}"/>" title="编辑"><i class="bi-pencil" style="font-size: 1.5em"></i></a>
                        <a href="<c:url value="/paid/delete?id=${paid.id}"/>" title="删除" onclick="return myConfirm();"><i class="bi bi-trash-fill" style="font-size: 1.5em"></i></a>
                    </td>
                </tr>
                </c:forEach>
                </tbody>
                <tfoot>
                <tr>
                    <td>合计</td>
                    <td colspan="3"></td>
                    <td><c:out value="${total}"/></td>
                    <td></td>
                </tr>
                </tfoot>
            </table>
        </div>
    </main>
    <jsp:include page="/include/footer.jsp"/>
    <script>
        function myConfirm() {
            return confirm('将要删除数据，是否继续？');
        }
    </script>
</body>
</html>
